package com.park.mer.controller.merorder;

import com.github.pagehelper.PageInfo;
import com.park.controller.BaseController;
import com.park.entity.mer.MerUserInfoLoginDto;
import com.park.entity.order.MerOrderStartEndDto;
import com.park.entity.page.PageInfoParm;
import com.park.mer.anno.MerUserToken;
import com.park.mer.service.order.MerOrderService;
import com.park.response.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Administrator
 * @title: MerOrderController
 * @projectName park
 * @description: 商户订单表
 * @date 2020/5/415:35
 */
@RestController
@RequestMapping(value = "/wx/merorder")
public class MerOrderController extends BaseController {

    @Autowired
    private MerOrderService merOrderService;

    /**
     　　* @description: 商户订单管理列表
     　　* @param [merUserInfoLoginDto]
     　　* @return {@link Result}
     　　* @throws
     　　* @author ZhangHaiWen
     　　* @version 2.0
     　　* @date 2020/5/4 15:47
     　　*/
    @MerUserToken
    @RequestMapping(value = "/orderList",method = RequestMethod.POST)
    public Result orderList(@RequestBody PageInfoParm<MerUserInfoLoginDto> merUserInfoLoginDto){
        Integer userId = getUserId();
        PageInfo pageInfo = merOrderService.orderList(merUserInfoLoginDto,userId);
        return SUCCESS(pageInfo);
    }

    /**
     　　* @description: 商户支付管理列表
     　　* @param [merUserInfoLoginDto]
     　　* @return {@link Result}
     　　* @throws
     　　* @author ZhangHaiWen
     　　* @version 2.0
     　　* @date 2020/5/4 15:47
     　　*/
    @MerUserToken
    @RequestMapping(value = "/payList",method = RequestMethod.POST)
    public Result payList(@RequestBody PageInfoParm<MerUserInfoLoginDto> merUserInfoLoginDto,Integer userId){
        PageInfo pageInfo = merOrderService.payList(merUserInfoLoginDto,userId);
        return SUCCESS(pageInfo);
    }

    /**
     　　* @description: 点击开始按钮
     　　* @param [merUserInfoLoginDto]
     　　* @return {@link Result}
     　　* @throws
     　　* @author ZhangHaiWen
     　　* @version 2.0
     　　* @date 2020/5/4 15:47
     　　*/
    @MerUserToken
    @RequestMapping(value = "/onstart",method = RequestMethod.POST)
    public Result onStart(@RequestBody MerOrderStartEndDto merUserInfoLoginDto){
        Integer userId = getUserId();
        merUserInfoLoginDto.setMerUserId(userId);
        merOrderService.onStart(merUserInfoLoginDto);
        return SUCCESS();
    }
    /**
     　　* @description: 点击结束按钮
     　　* @param [merUserInfoLoginDto]
     　　* @return {@link Result}
     　　* @throws
     　　* @author ZhangHaiWen
     　　* @version 2.0
     　　* @date 2020/5/4 15:47
     　　*/
    @MerUserToken
    @RequestMapping(value = "/onend",method = RequestMethod.POST)
    public Result onEnd(@RequestBody MerOrderStartEndDto merUserInfoLoginDto){
        Integer userId = getUserId();
        merUserInfoLoginDto.setMerUserId(userId);
        merOrderService.onEnd(merUserInfoLoginDto);
        return SUCCESS();
    }


}
